﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AMS.DD35.WebMVP.Models;

namespace AMS.DD35.WebMVP.Presenters
{
    public class RegisterPresenter
    {
        IRegisterView _view;
        IRegisterModel _model;

        public RegisterPresenter(IRegisterView view, IRegisterModel registerModel)
        {
            this._view = view;
            this._model = registerModel;
        }

        public void Register()
        {
            _model.Register(_view.UserName, _view.FirstName, _view.LastName, _view.Password, _view.EmailAddress);
        }

        internal void RegisterFailed()
        {
            _view.Message = "Registration Failed!";
            // TODO: differentiate between User Exists and failed for no reason
        }

        internal void RegisterSucceeded()
        {
            _view.UserName = String.Empty;
            _view.FirstName = String.Empty;
            _view.LastName = String.Empty;
            _view.Password = String.Empty;
            _view.ConfirmPassword = String.Empty;
            _view.EmailAddress = String.Empty;
            _view.ConfirmEmail = String.Empty;
            _view.Message = "Registration Successful!";
        }
    }
}